package cn.schoolwow.workflow.module.task.query.service;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickdao.domain.database.dql.condition.Condition;
import cn.schoolwow.quickdao.domain.database.dql.response.PageVo;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.workflow.domain.task.WorkFlowTaskResponse;
import cn.schoolwow.workflow.module.task.query.flow.SetTaskQueryConditionFlow;

public class GetPagingTaskListServiceFlow implements BusinessFlow {

    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        flowContext.executeFlowList(new SetTaskQueryConditionFlow());

        int pageNumber = flowContext.getData("pageNumber", int.class, 1);
        int pageSize = flowContext.getData("pageSize", int.class, 10);
        Condition condition = flowContext.checkInstanceData(Condition.class);
        DAO dao = flowContext.checkInstanceData(DAO.class);

        dao.addRecordString("分页查询工作流任务列表");
        PageVo<WorkFlowTaskResponse> pageVo = condition.page(pageNumber, pageSize)
                .execute()
                .getPagingList(WorkFlowTaskResponse.class);
        flowContext.putTemporaryData("pageVo", pageVo);
    }

    @Override
    public String name() {
        return "分页查询工作流任务服务流程";
    }
}
